<?php
class ORMPackageItem extends ORMBase {
  public function __construct() {
    parent::__construct('PackageItem');
  }

  public function __toEpObject($myManager, $epObject, $object) {
    require_once dirname(__FILE__) . '/ORMPackageItemSelect.class.php';
    require_once dirname(__FILE__) . '/ORMSample.class.php';
    $epObject->trackId = isset($object->trackId) ? $object->trackId : '';
    if (isset($object->sample) && $object->sample) {
        $epObject->sample = $this->__getEpObject_4_lvl_1_object($myManager, $object->sample, new ORMSample(), 'Sample');
    } else {
      if (isset($epObject->sample)) {
        $myManager->delete($epObject->sample);
      }
    }
    $epObject->quantity = isset($object->quantity) ? $object->quantity : 0;
    $epObject->total = isset($object->total) ? $object->total : 0;
    $epObject->otherId = isset($object->otherId) ? $object->otherId : '';
    if (isset($epObject->selects)) {
      $epObject->selects->removeAll();
      foreach ($object->selects as &$item) {
        $epObject->selects[] = $this->__getEpObject_4_lvl_1_object($myManager, $item, new ORMPackageItemSelect(), 'PackageItemSelect');
      }
    }
    return $epObject;
  }

  public function __toObject($myManager, $epObject, $object) {
    require_once dirname(__FILE__) . '/ORMPackageItemSelect.class.php';
    require_once dirname(__FILE__) . '/ORMSample.class.php';
    $object->id = $epObject->oid;
    $object->trackId = $epObject->trackId;
    if (isset($epObject->sample)) {
      $object->sample = $this->__getObject_4_lvl_1_ep_object($myManager, $epObject->sample, new ORMSample());
    }
    $object->quantity = $epObject->quantity;
    $object->total = $epObject->total;
    $object->otherId = $epObject->otherId;
    $object->selects = array();
    if (isset($epObject->selects)) {
      foreach ($epObject->selects as &$item) {
        $object->selects[] = $this->__getObject_4_lvl_1_ep_object($myManager, $item, new ORMPackageItemSelect());
      }
    }
    return $object;
  }
}
?>
